#include "WidgetWrapper.h"

namespace BerkeliumDotNet
{
	Widget::Widget(Berkelium::Widget* widget)
	{
		this->widget = widget;
	}

	Widget::~Widget()
	{
		delete widget;
		widget = 0;
	}

	void Widget::Focus()
	{
		widget->focus();
	}

	void Widget::Unfocus()
	{
		widget->unfocus();
	}

	void Widget::MouseMoved(int xPos, int yPos)
	{
		widget->mouseMoved(xPos, yPos);
	}
	
	void Widget::MouseButton(unsigned int buttonId, bool down)
	{
		widget->mouseButton(buttonId, down);
	}
	
	void Widget::MouseWheel(int xScroll, int yScroll)
	{
		widget->mouseWheel(xScroll, yScroll);
	}

	void Widget::TextEvent(char event, size_t eventLength)
	{
		widget->textEvent((const wchar_t*)event, eventLength);
	}

	void Widget::KeyEvent(bool pressed, int modifiers, int vkCode, int scancode)
	{
		widget->keyEvent(pressed, modifiers, vkCode, scancode);
	}

	System::Drawing::Rectangle^ Widget::Rectangle::get()
	{
		Berkelium::Rect rect = widget->getRect();
		return gcnew System::Drawing::Rectangle(rect.mLeft, rect.mTop, rect.mWidth, rect.mHeight);
	}

	void Widget::SetPosition(int x, int y)
	{
		widget->setPos(x, y);
	}
}
